package com.brickworkers.codemaker.service;

import static com.brickworkers.codemaker.utils.MakerconfResource.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.brickworkers.codemaker.utils.MakerconfResource;

public class SqlConnectionFactory {
	
	public static volatile Connection instance;
	
	/**
	 * 默认使用mysql的驱动
	 * @author brickworker
	 * @param url
	 * @param user
	 * @param password
	 * @return
	 */
	public static Connection getConnection(){
		if(instance == null){
			synchronized(SqlConnectionFactory.class){
				if(instance == null){
					try {
						Class.forName(rb.getString("sql.driver"));
						instance = DriverManager.getConnection(rb.getString("sql.url"), rb.getString("sql.user"), rb.getString("sql.password"));
					} catch (ClassNotFoundException e) {
						e.printStackTrace();
					} catch (SQLException e) {
						e.printStackTrace();
					}
					
				}
			}
		}
		return instance;
	}
	
	
}
